<style scoped src="./index.scss" lang="scss" rel="stylesheet/scss"></style>
<template src="./index.html"></template>
<script>
import Edit from "./../edit/index";
import Reject from "./../reject/index";
export default {
  mixins: [
    Vue.prototype.$vFN.Mixins.Base,
    Vue.prototype.$vFN.Mixins.Page,
    Vue.prototype.$vFN.Mixins.Table,
  ],
  components: {},
  data() {
    return {
      appWindow: window,
      // 页面接口地址
      apiUrl: {
        list: "admin/store/apply",
        // delete: "admin/category/del",
      },
      // 表格查询数据
      mixinTable_tableSearchData: {
        name: "",
      },
      // 表格数据
      tableData: [],
      // 表格数据删除展示结构
      tableDeleteConfig: {
        columns: [
          {
            label: "标签名称",
            prop: "name",
            type: "",
          },
          {
            label: "绑定商品数",
            prop: "productCount",
            type: "",
          },
        ],
      },
    };
  },
  methods: {
    // 打开添加/修改
    editBoxOpen(params_) {
      Edit.init({
        mixinEdit_parent: this,
        mixinEdit_editType: params_.type,
        id: params_.id,
      });
    },
    // 详情
    details(params_) {
      Edit.init({
        mixinEdit_parent: this,
        mixinEdit_editType: params_.type,
        id: params_.id,
        data: params_.data,
        onSuccess: (res) => {
          this.mixinTable_refreshData();
        }
      });
    },
    // 驳回审核
    reject(params_) {
      Reject.init({
        mixinEdit_parent: this,
        mixinEdit_editType: params_.type,
        id: params_.id,
        data: params_.data,
        onSuccess: (res) => {
          this.mixinTable_refreshData();
        }
      });
    },
    // 初始化
    async init() {
      this.mixinTable_refreshData();
    },
    pass(id) {
      this.$confirm("确定进行此操作吗？", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        // type: "error",
        dangerouslyUseHTMLString: true,
      })
        .then(async () => {
          let res = await this.$vFN.Http.post(
            {
              url: "admin/store/pass",
              data: {
                id: id,
              },
            },
            window
          );
          this.mixinTable_refreshData();
          if (res.success) {
            this.$vFN.Tools.messageSuccess("操作成功");
            this.editBoxClose();
          }
        })
        .catch(() => {});
    },
  },
  filters: {
      statuName: function(value) {
        let text;
        switch(parseInt(value)){
            case -2:
              text = "已过期"
            break;
            case -1:
              text = "被拒绝"
            break;
            case 0:
              text = "申请中"
            break;
            case 1:
              text = "使用中"
            break;
            default:
              text = "-"
        }
        return text
      }
  },
  mounted() {
    this.init();
  },
  activated() {},
};
</script>